package com.xy.tianyu.module.picture.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xy.tianyu.R
import com.xy.tianyu.module.picture.bean.PicSearchMultipleItem
import com.xy.tianyu.module.picture.bean.PicTodayHotMultipleItem
import com.xy.tianyu.utils.GlideUtils
import kotlinx.android.synthetic.main.item_pic_today_hot_hor.view.*
import kotlinx.android.synthetic.main.item_pic_today_hot_square.view.*
import kotlinx.android.synthetic.main.item_pic_today_hot_ver.view.*


/**
 * @time 2020/10/14 14:35
 * @class 描述:
 */
class PicSearchAdapter (data:MutableList<PicSearchMultipleItem>):
    BaseMultiItemQuickAdapter<PicSearchMultipleItem, BaseViewHolder>(data){
    init {
        addItemType(PicTodayHotMultipleItem.PIC_HOT_TODAY_HOR, R.layout.item_pic_today_hot_hor)
        addItemType(PicTodayHotMultipleItem.PIC_HOT_TODAY_VER, R.layout.item_pic_today_hot_ver)
        addItemType(PicTodayHotMultipleItem.PIC_HOT_TODAY_SQUARE, R.layout.item_pic_today_hot_square)
    }

    override fun convert(holder: BaseViewHolder, item: PicSearchMultipleItem) {
        val picSearch1 = item.picSearchItem1
        val picSearch2 = item.picSearchItem2

        when(item.itemType){
            PicTodayHotMultipleItem.PIC_HOT_TODAY_HOR -> {
                Glide.with(context).load(picSearch1.thumbURL).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_hor)
            }
            PicTodayHotMultipleItem.PIC_HOT_TODAY_VER -> {
                Glide.with(context).load(picSearch1.thumbURL).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_ver_one)
                Glide.with(context).load(picSearch2.thumbURL).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_ver_two)
            }
            PicTodayHotMultipleItem.PIC_HOT_TODAY_SQUARE -> {
                Glide.with(context).load(picSearch1.thumbURL).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_square_one)
                Glide.with(context).load(picSearch2.thumbURL).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_square_two)
            }
        }
    }
}